//
//  RNavigationViewController.m
//  iAccountBook
//
//  Created by 侯伟 on 2021/9/30.
//

#import "RNavigationViewController.h"

@interface RNavigationViewController ()

@end

@implementation RNavigationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationBar.translucent = NO;
    self.navigationBar.tintColor = COLOR_WHITE;
    self.navigationBar.barTintColor =  COLOR_THEME;
    
    self.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:COLOR_WHITE,NSFontAttributeName:FONTMID(16)};
    
    [[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[UINavigationBar.class]] setBackButtonTitlePositionAdjustment:UIOffsetMake(-500, 0) forBarMetrics:(UIBarMetricsDefault)];
    
    [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[UINavigationBar.class]].tintColor = COLOR_WHITE;
    UIImage* backImage = [UIImage imageNamed:@"common_back_white"];
    self.navigationBar.backIndicatorImage = backImage;
    self.navigationBar.backIndicatorTransitionMaskImage = backImage;
    
    if (@available(iOS 15.0, *)) {
        UINavigationBarAppearance *appearance = [self.navigationBar.standardAppearance copy];
        [appearance configureWithTransparentBackground];
        appearance.titleTextAttributes =  @{NSForegroundColorAttributeName:COLOR_WHITE,NSFontAttributeName:FONTMID(16)};
        appearance.shadowColor = UIColor.clearColor;
        appearance.shadowImage = [UIImage new];
        appearance.backgroundColor =  COLOR_THEME;
        appearance.backButtonAppearance.normal.titlePositionAdjustment = UIOffsetMake(-500, 0);
        [appearance setBackIndicatorImage:[UIImage imageNamed:@"common_back_white"] transitionMaskImage:[UIImage imageNamed:@"common_back_white"]];
        self.navigationBar.standardAppearance = appearance;
        self.navigationBar.scrollEdgeAppearance= self.navigationBar.standardAppearance;
        
    }
    
    [self hiddenNavigationBarSeparatorLine:YES];
}

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
    BOOL hidde = [viewController isKindOfClass:NSClassFromString(@"RMineViewController")] || [viewController isKindOfClass:NSClassFromString(@"RVideoDetailsViewController")] || [viewController isKindOfClass:NSClassFromString(@"RCachePlayerViewController")] || [viewController isKindOfClass:NSClassFromString(@"RShareViewController")];
    [self setNavigationBarHidden:hidde animated:YES];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
